$(function(){
	var api = '';
	var page = 0,page_size = 20,page_count='';
	get_next_page(0,10)

	
	$(window).scroll(function() { //上拉加载
		if ($(document).scrollTop() <= 0) {
		    console.log( '顶部' )
		}
		if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
			page++;//当前需要请求的页数
		    var totalPage = Math.ceil(page_count/10)-1//总的页数;
		    if( page <= totalPage  ){
		    	get_next_page( page,10)
		    }
		}
	});
	
	
	function get_next_page(page,num){
		$.ajax({
		type:"get",
		dataType:'json',
		url: api+"/hotelp/api/get-daren-data?page="+page+"&page_size="+num,
		success:function(data){ //加载首页数据
			var status =  data.status,list="";
			if( status == 1 ){
				//console.log( data )
				page_count = data.msg.page_count
				$.each(data.msg.data, function(n,value) {
					list +='<li><span>'+ value.rank +'</span><span>'+ value.id +'</span><span>'+ value.user_name +'</span><span>'+ value.clickz_count +'</span></li>'
				});
				$('.js_ranking_item').append( list )
			}
		}
	});
	}
	
})
